package com.sy.service.Impl;

import com.sy.constant.Method;
import com.sy.dto.JsonResult;
import com.sy.entity.Permission;
import com.sy.exception.QuestionException;
import com.sy.repository.PermissionRepository;
import com.sy.repository.RoleRepository;
import com.sy.service.PermissionService;
import com.sy.utils.HttpUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.transform.Result;
import java.util.List;

/**
 * @author zbbstart
 * @date 2021/1/30 - 23:57
 */
@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionRepository permissionRepository;
    @Autowired
    private HttpUtils httpUtils;

    @Override
    public JsonResult getPermissionList() {
        JsonResult result = new JsonResult();
        List<Permission> permissionList = permissionRepository.findAll();
        if (CollectionUtils.isEmpty(permissionList)) {
            result = httpUtils.buildFailure("无信息", Method.GET);
        } else {
            result = httpUtils.buildSuccess(Method.GET, permissionList);
        }
        return result;
    }
}
